package com.huawei.appmarket.service.usercenter.userinfo.view.widget;

import android.content.Context;
import android.os.Handler;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.huawei.appmarket.service.usercenter.userinfo.bean.UserInfoBean;
import huawei.widget.HwButton;
import o.azb;
import o.der.d;
import o.der.f;
import o.der.g;
import o.dof;
import o.emj;
import o.emn;

public class ReceiverInfoAddView extends LinearLayout {
    protected UserInfoBean ʻ;
    OnClickListener ʼ = new OnClickListener(this) {
        final /* synthetic */ ReceiverInfoAddView ॱ;

        {
            this.ॱ = r1;
        }

        public void onClick(View view) {
            if (view == this.ॱ.ʽ) {
                boolean ˋ = this.ॱ.ˋ();
                if (this.ॱ.ʻ == null) {
                    Toast.makeText(this.ॱ.ˊ, f.ᐝʼ, 0).show();
                } else if (ˋ && this.ॱ.ॱॱ != null) {
                    this.ॱ.ॱॱ.ˎ(this.ॱ.ʻ);
                }
            } else if (view == this.ॱ.ˏॱ || view == this.ॱ.ͺ) {
                this.ॱ.ˏॱ.setFocusableInTouchMode(true);
                this.ॱ.ˏॱ.setFocusable(true);
                this.ॱ.ˏॱ.requestFocus();
                if (this.ॱ.ॱॱ != null) {
                    this.ॱ.ॱॱ.ˎ();
                }
            }
        }
    };
    protected HwButton ʽ;
    protected Context ˊ;
    private TextWatcher ˊॱ;
    protected CheckBox ˋ;
    private EditText ˋॱ;
    protected LinearLayout ˎ;
    protected TextView ˏ;
    private TextView ˏॱ;
    private View ͺ;
    protected TextView ॱ;
    protected emn ॱॱ;
    OnCheckedChangeListener ᐝ = new OnCheckedChangeListener(this) {
        final /* synthetic */ ReceiverInfoAddView ˋ;

        {
            this.ˋ = r1;
        }

        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
            if (this.ˋ.ʽ != null) {
                this.ˋ.ʽ.setEnabled(compoundButton.isChecked());
            }
        }
    };

    public ReceiverInfoAddView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ˊ = context;
        ˏ();
    }

    public ReceiverInfoAddView(Context context) {
        super(context);
        this.ˊ = context;
        ˏ();
    }

    protected void ˏ() {
        View inflate = LayoutInflater.from(this.ˊ).inflate(g.ᐧ, this);
        azb.ˏ(inflate, d.ˊ);
        this.ˎ = (LinearLayout) inflate.findViewById(d.ˊˉ);
        this.ˏ = (EditText) inflate.findViewById(d.ˊᐨ);
        this.ˏॱ = (TextView) inflate.findViewById(d.ˊˈ);
        this.ॱ = (EditText) inflate.findViewById(d.ˊʾ);
        this.ˋॱ = (EditText) inflate.findViewById(d.ˊꜟ);
        this.ˋ = (CheckBox) inflate.findViewById(d.ᶥ);
        azb.ˋ(this.ˋ);
        this.ʽ = (HwButton) inflate.findViewById(d.ᐝˋ);
        this.ʽ.setEnabled(false);
        this.ͺ = inflate.findViewById(d.ᐨॱ);
        this.ˏ.setOnClickListener(this.ʼ);
        this.ˏॱ.setOnClickListener(this.ʼ);
        this.ॱ.setOnClickListener(this.ʼ);
        this.ˋॱ.setOnClickListener(this.ʼ);
        ˊॱ();
        this.ˋॱ.addTextChangedListener(this.ˊॱ);
        this.ˋ.setOnCheckedChangeListener(this.ᐝ);
        this.ʽ.setOnClickListener(this.ʼ);
        this.ͺ.setOnClickListener(this.ʼ);
    }

    private void ˊॱ() {
        this.ˊॱ = new TextWatcher(this) {
            final /* synthetic */ ReceiverInfoAddView ˊ;

            {
                this.ˊ = r1;
            }

            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                this.ˊ.ˋॱ.setFilters(new InputFilter[]{new LengthFilter(11)});
            }

            public void afterTextChanged(Editable editable) {
            }
        };
    }

    protected boolean ˋ() {
        if (this.ʻ == null) {
            this.ʻ = new UserInfoBean();
        }
        return ˎ() && ॱ() && ˊ() && ॱॱ();
    }

    protected boolean ˎ() {
        String obj = this.ˏ.getEditableText().toString();
        if (dof.ˋ(obj)) {
            Toast.makeText(this.ˊ, f.ˈᐝ, 0).show();
            return false;
        } else if (obj.contains(emj.ˋ)) {
            Toast.makeText(this.ˊ, f.ˈˋ, 0).show();
            return false;
        } else {
            this.ʻ.ˏ(obj);
            return true;
        }
    }

    protected boolean ॱ() {
        String charSequence = this.ˏॱ.getText().toString();
        if (dof.ˋ(charSequence)) {
            Toast.makeText(this.ˊ, f.ʿˋ, 0).show();
            return false;
        }
        this.ʻ.ॱ(charSequence);
        return true;
    }

    protected boolean ˊ() {
        String obj = this.ॱ.getEditableText().toString();
        if (dof.ˋ(obj)) {
            Toast.makeText(this.ˊ, f.ʾˋ, 0).show();
            return false;
        } else if (obj.contains(emj.ˋ)) {
            Toast.makeText(this.ˊ, f.ʿᐝ, 0).show();
            return false;
        } else {
            this.ʻ.ˋ(obj);
            return true;
        }
    }

    protected boolean ॱॱ() {
        String ᐝ = ᐝ();
        if (!dof.ˋ(ᐝ) && !ˎ(this.ˋॱ, ˊ(this.ʻ.ˊ()))) {
            return true;
        }
        boolean z;
        if (!dof.ˋ(ᐝ) && ᐝ.length() == 11 && emj.ˎ(ᐝ)) {
            z = true;
        } else {
            z = false;
        }
        if (z) {
            this.ʻ.ˎ(ᐝ);
            return true;
        }
        Toast.makeText(this.ˊ, f.ˉᐝ, 0).show();
        return false;
    }

    protected String ᐝ() {
        if (ˎ(this.ˋॱ, ˊ(this.ʻ.ˊ()))) {
            return this.ˋॱ.getEditableText().toString();
        }
        return this.ʻ.ˊ();
    }

    public void setInterfaceAndUserInfo(emn o_emn, UserInfoBean userInfoBean) {
        this.ॱॱ = o_emn;
        this.ʻ = userInfoBean;
        if (this.ʻ != null) {
            ˏॱ();
        }
    }

    private void ˏॱ() {
        new Handler().postDelayed(new Runnable(this) {
            final /* synthetic */ ReceiverInfoAddView ˋ;

            {
                this.ˋ = r1;
            }

            public void run() {
                this.ˋ.ʽ();
            }
        }, 200);
    }

    protected void ʽ() {
        if (!dof.ˋ(this.ʻ.ʼ())) {
            this.ˏ.setText(this.ʻ.ʼ());
        }
        ʻ();
        if (!dof.ˋ(this.ʻ.ˋ())) {
            this.ॱ.setText(this.ʻ.ˋ());
        }
        ʼ();
    }

    protected void ʻ() {
        if (!dof.ˋ(this.ʻ.ˎ())) {
            this.ˏॱ.setText(this.ʻ.ˎ());
        }
    }

    protected void ʼ() {
        if (!dof.ˋ(this.ʻ.ˊ())) {
            this.ˋॱ.setText(ˊ(this.ʻ.ˊ()));
            new emj(50).ॱ(this.ˋॱ, this.ˋॱ.getText().toString());
        }
    }

    public void setAreaInfo(String str) {
        this.ˏॱ.setText(str);
    }

    public boolean ˋॱ() {
        String str;
        String str2;
        String str3;
        String str4;
        if (this.ʻ == null) {
            str = "";
            str2 = "";
            str3 = "";
            str4 = "";
        } else {
            str = this.ʻ.ʼ();
            str2 = this.ʻ.ˎ();
            str3 = this.ʻ.ˋ();
            str4 = this.ʻ.ˊ();
        }
        return ˎ(this.ˏ, str) || ॱ(str2) || ˎ(this.ॱ, str3) || ˏ(ˊ(str4));
    }

    protected boolean ॱ(String str) {
        return ˎ(this.ˏॱ, str);
    }

    protected boolean ˏ(String str) {
        return ˎ(this.ˋॱ, str);
    }

    protected String ˊ(String str) {
        return emj.ˊ(str);
    }

    protected boolean ˎ(TextView textView, String str) {
        return !ॱ(textView).equals(str);
    }

    private String ॱ(TextView textView) {
        if (textView instanceof EditText) {
            return textView.getEditableText().toString();
        }
        return textView.getText().toString();
    }
}
